package com.example.swagger2.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * swagger2测试,http://localhost:8080/swagger-ui.html,端口同应用服务端口
 */
@Api
@RestController
public class HelloController {

    @ApiOperation("这是个hello入口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "测试名字", required = false, defaultValue = "Hello"),
            @ApiImplicitParam(name = "age", value = "测试年龄", required = false, defaultValue = "1")
    })
    @GetMapping("/hello")
    public ResponseEntity<?> hello(String name, Integer age){
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("name", name);
        stringObjectHashMap.put("age", age);
        return new ResponseEntity<>(stringObjectHashMap, HttpStatus.OK);
    }
}
